/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ControlLayer;
import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;
/**
 *
 * @author Stefan
 */
public class CtrCustomer
{
    /** Creates a new instance of CtrCustomer */
    public CtrCustomer() {

    }
    public ArrayList findAllCustomer()
    {
      IFDBCustomer dbCus = new DBCustomer();
      ArrayList allCus = new ArrayList();
      allCus = dbCus.getAllCustomer(false);
      return allCus;
    }
    public Customer findByName(String name)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.searchCustomerName(name, true);
    }

    public Customer findByID(int id)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.findCustomer( id, true);
    }

    public int updateCus(int id, String name, String address, String pCode, String cCode, String phoneNo)
    {
          IFDBCustomer dbCus = new DBCustomer();
          Customer cus = new Customer();
          cus.setCustomerID(id);
          cus.setName(name);
          cus.setAddress(address);
          cus.setZipCode(pCode);
          cus.setCountryCode(cCode);
          cus.setPhoneNo(phoneNo);
          return  dbCus.updateCustomer(cus);
    }

    public void insertNew(Customer cusObj)
    {
       IFDBCustomer dbCus = new DBCustomer();
       dbCus.insertCustomer(cusObj);
    }

    public void deleteCustomer(int id)
    {
        IFDBCustomer dbCus = new DBCustomer();
        dbCus.deleteCustomer(id);
    }
}
